index.md (1115B)
1 +++ 2 title = 'Addition/subtraction logic unit' 3 template = 'page-math.html' 4 +++ 5 # Addition/subtraction logic unit 6 ## Adders 7 A half adder takes two inputs, produces sum and carry-out. 8 9 A full adder also takes a carry-in. 10 11 You can easily get this from a truth table: 12 13 ![screenshot.png](screenshot-52.png) 14 15 You can make a circuit out of this. Inputs are x, y, and carry. Carry out is $c_{i+1}$: 16 17 | Sum | Carry | 18 | --- | --- | 19 | ![screenshot.png](screenshot-54.png) | ![screenshot.png](screenshot-51.png) | 20 21 That’s represented by the symbol: 22 23 ![Screen Shot](shot.png) 24 25 If you want to add n bits, you stick a bunch of them together and make an *n*-bit ripple-carry adder. $x_{n-1}$ and $y_{n-1}$ are the sign bits: 26 27 ![screenshot.png](screenshot-55.png) 28 29 ## Detecting overflow 30 Remember that the final carry out is not a part of the result. 31 It’s an overflow when: 32 33 - the sign of the sum is different from the sign of the summands 34 - or the carry-out bits are different 35 36 Two logical expressions for detecting overflow (either works): 37 38 ![](a5b4b0e66c6d8e53ab1bfbcf8f5c2d49.png) 39 ![screenshot.png](screenshot-53.png)